package qimao.com.edu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import qimao.com.edu.DTO.ChapterDTO;
import qimao.com.edu.entity.CategoryMajor;
import qimao.com.edu.entity.CategoryMinor;
import qimao.com.edu.entity.CommenResult;
import qimao.com.edu.entity.Page;
import qimao.com.edu.service.CategoryService;
import qimao.com.edu.service.impl.CategoryServiceImpl;

@WebServlet("/AllMajorList.do")
public class SeleMajor  extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("application/json;charset=UTF-8");
		
		CategoryService cs = new CategoryServiceImpl();
		List<CategoryMajor> majorList = cs.getAllMajorCategories();
		
		CommenResult cr = new CommenResult();
		cr.setCode(200);
		cr.setMsg("success");
		cr.setData(majorList);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().write(cr.toJsonString());
	}
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
}
